package com.kede.app.domain;

import com.kede.app.service.dto.LeescoreGoodsTypeDto;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
* @description /
* @author Pr.li
* @date 2023-05-23
**/
@Entity
@Data
@Table(name="sy_leescore_goods_type")
@EntityListeners(AuditingEntityListener.class)
public class LeescoreGoodsType implements Serializable {
    /**
    * 
    */
    @ApiModelProperty(value = "id")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    private Integer id;
    /**
    * 主选项id
    */
    @ApiModelProperty(value = "主选项id")
    @Column(name = "`pid`",nullable = false)
    private Integer pid;
    /**
    * 选项名称
    */
    @ApiModelProperty(value = "选项名称")
    @Column(name = "`name`",nullable = false)
    @NotBlank
    private String name;
    /**
    * 选项别名，用于快速查找name
    */
    @ApiModelProperty(value = "选项别名，用于快速查找name")
    @Column(name = "`tag`",nullable = false)
    private String tag;
    /**
    * 选项状态  1启动 2禁用
    */
    @ApiModelProperty(value = "选项状态  1启动 2禁用")
    @Column(name = "`status`",nullable = false)
    @NotNull
    private Integer status;
    /**
    * 1 主选项 2子选项
    */
    @ApiModelProperty(value = "1 主选项 2子选项")
    @Column(name = "`type`",nullable = false)
    @NotNull
    private Integer type;

    /**
     * 备注
     **/
    @ApiModelProperty(value = "备注")
    @Column(name = "`remark`")
    private String remark;
    /**
    * 
    */
    @ApiModelProperty(value = "createTime")
    @Column(name = "`create_time`")
    @CreatedDate
    private Timestamp createTime;
    /**
    * 
    */
    @ApiModelProperty(value = "updateTime")
    @Column(name = "`update_time`")
    @LastModifiedDate
    private Timestamp updateTime;

    @Transient
    private Boolean hasChildren;
    @Transient
    private List<LeescoreGoodsType> children;

    public void copy(LeescoreGoodsType source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
